<?php

namespace App\Http\Controllers\cms;

use App\Engine\BaseController;
use App\Http\Validate\BannerValidate;
use App\Models\Banner as BannerModel;
use function app\Utils\go;


class Banner extends BaseController
{
    /**获取广告图
     * @return array
     */
    public function get()
    {
        return go(BannerModel::get_banner());
    }

    /**更新广告信息
     * @return array
     * @throws \Illuminate\Validation\ValidationException
     */
    public function update()
    {
        $this->validate($this->request,BannerValidate::$rule,BannerValidate::$message);
        return go(BannerModel::update_banner($this->post));

    }

    /**插入广告
     * @return array
     * @throws \Illuminate\Validation\ValidationException
     */
    public function insert()
    {
        $this->validate($this->request,BannerValidate::$rule,BannerValidate::$message);
        return go(BannerModel::insert_banner($this->post));
    }

    /**删除广告信息
     * @return array
     */
    public function del()
    {
        return go(BannerModel::del_banner($this->get['id']));
    }
}
